<?php

namespace App\Http\Api\Controllers;

use App\Exceptions\InvalidRequestException;
use App\Http\Admin\Services\AuthService;
use App\Http\Api\Services\ProductService;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;


class ProductController extends Controller
{
    protected $productService;

    public function __construct(ProductService $productService)
    {
        $this->productService = $productService;
    }



    /*
     * 商品采集
     * */
    public function store(Request $request)
    {
        $attributes = $request->input('data') ?? null;

        $result = $this->productService->store($attributes);

        return res('采集完成',$result);
    }

    /*
     * 商品sku采集
     * */
    public function skuStore(Request $request)
    {
        $attributes = $request->input('data') ?? null;

        $result = $this->productService->skuStore($attributes);

        return res('采集完成',$result);
    }

    /*
    * 商品sku库存查询
    * */
    public function skuStock(Request $request)
    {
        $prod_no = $request->input('prod_no') ?? null;

        $result = $this->productService->skuStock($prod_no);

        return $result;
    }

    /*
     * 商品微信登记
     * */
    public function reg(Request $request)
    {
        $attributes = $request->all();

        $result = $this->productService->reg($attributes);

        return res('登记完成',$result);
    }

    /*
     * 客户反馈登记
     * */
    public function feedback(Request $request){
        $attributes = $request->all();

        $result = $this->productService->feedback($attributes);

        return res('登记完成',$result);
    }


    /*
     * 商品条目
     * */
    public function productItem(Request $request){
        $prod_no = $request->input('prod_no') ?? '';

        $result = $this->productService->productItem($prod_no);

        return res('条目',$result);
    }


    /*
     * 客户反馈是否已读
     * */
    public function isReadFeedback(Request $request){
        $attrs = $request->all();

        $result = $this->productService->isReadFeedback($attrs);

        return res('ok',$result);
    }

    /*
     * 反馈数据列表
     * */
    public function userFeedbackList(Request $request){
        $attrs = $request->all();

        $result = $this->productService->userFeedbackList($attrs);

        return res('ok',$result);
    }



}
